import { createApp } from 'vue'
import App from './App.vue'
import router from '../src/router/index'
import './assets/common.css'  //导入公共样式
import './assets/iconfont/iconfont.css'
import { createPinia } from 'pinia'
import piniaPluginPersist from 'pinia-plugin-persist';
import ElementPlus from 'element-plus'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'element-plus/dist/index.css'
import elTableInfiniteScroll from 'el-table-infinite-scroll';
import './rem'
import i18n from './assets/lang/index'  //国际化


const pinia = createPinia()
pinia.use(piniaPluginPersist);
const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    //全局icon
    app.component(key, component)
  }
// app.directive('loadmore', (el, binding) => {
//     const child = el.querySelector('.select-trigger')
//     const id = child.getAttribute('aria-describedby')
//     const poper = document.getElementById(id)
//     const SELECTDOWN_DOM = poper && poper.querySelector('.el-scrollbar .el-select-dropdown__wrap')
//     SELECTDOWN_DOM && SELECTDOWN_DOM.addEventListener('scroll', function () {
//         const CONDITION = this.scrollHeight - this.scrollTop <= this.clientHeight;
//         if (CONDITION) {
//             binding.value();
//         }
//     })
// })
app.use(router)
app.use(ElementPlus)
app.use(elTableInfiniteScroll);
app.use(i18n);
app.use(pinia)
app.config.warnHandler = () => null;
app.mount('#app')